#include "insettingdlg.h"
#include "ui_insettingdlg.h"
#include "inputfunction.h"

InSettingDlg::InSettingDlg(Input* input,QWidget *parent) :
    BaseEditor(QModelIndex(),parent),mInput(input),
    ui(new Ui::InSettingDlg)
{
    ui->setupUi(this);
    setWindowFlags(Qt::FramelessWindowHint);
    this->setGeometry(WINDOW_GEOMETRY_SHIFT(0.4,0.4,0));
    initDlg();
}

InSettingDlg::~InSettingDlg()
{
    delete ui;
}

void InSettingDlg::initDlg()
{
    QStringList itemNameList = inMgr->functionNameList();
    ui->cbxFunc->addItems(itemNameList);
    ui->cbxFunc->setCurrentIndex(mInput->getFunctionNum());
    QStringList normaStatusList = inMgr->normalStatusList();
    ui->cbxNormal->addItems(normaStatusList);
    ui->cbxNormal->setCurrentIndex(mInput->getNormalStatus());
}

void InSettingDlg::on_btn_cancel_clicked()
{
    this->reject();
}

void InSettingDlg::on_btn_ok_clicked()
{
    uint no = mInput->getNo();
    uint normalstatus = ui->cbxNormal->currentIndex();
    uint functionNum = ui->cbxFunc->currentIndex();
    inMgr->saveInputFunction(no,normalstatus,functionNum);
    this->accept();
}
